package com.back.campus_back.controller;


import com.back.campus_back.domain.ReportGoods;
import com.back.campus_back.service.ReportGoodsService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-04-17
 */
@RestController
@RequestMapping("/report-goods")
public class ReportGoodsController {

    @Autowired
    private ReportGoodsService reportGoodsService;


    //根据商品id获取评论
    @GetMapping("/getReport/{goods_id}")
    public List getReport(@PathVariable("goods_id") Integer goods_id){
        List list = reportGoodsService.getReport(goods_id);
        return list;

    }

    //发表评论
    @PostMapping("/addReport")
    public String addReport(@RequestBody ReportGoods reportGoods){
        return reportGoodsService.addReport(reportGoods);
    }


    //查看所有评论
    @GetMapping("/findAllReport")
    public List findAllReport(){
        List allReport = reportGoodsService.findAllReport();
        return allReport;
    }



}

